package day06;

public class MaxDemo {
    public static void main(String[] args) {
        int [] a={12,1,47,15,12,3,148,75,44,41,5,54,56,1,51,5,3,14,54,5,41,1,15};
        int max=getMaxOfArray(a);
        System.out.println(max);
     long v=15;
     int d=(int)v;
    }


    public static int getMaxOfArray(int[] a) {

           /* int max = a[0]; //假设第1个元素为最大值
            for(int i=1;i<a.length;i++){ //遍历剩余元素
                if(a[i]>max){   //若剩余元素大于max
                    max = a[i]; //将max修改为较大的*/
        int max=a[0];
        for (int i = 1; i < a.length; i++) {
            if (a[i] > a[0]) {
                a[0] = a[i];

            }

        }
        return max;

    }

}